function printerTest()
{
	var printer = new Printer(Printer.ScreenResolution),
		w = mainWindow.activeDocument,
		pages = w.pages(),
		i = 0,
		addPage = false,
		file = FileDialog.getSaveFileName("Pdf (*.pdf)", "Save file");

	printer.paperSize = Printer.A4;//by default uses the one in the document
	printer.begin(file)
	for (i = pages.length - 1; i >= 0; --i) {
		if (addPage) {
			printer.newPage();
		} else {
			addPage = true;
		}
		printer.print(pages[i]);		
	}
	printer.end();
}